package builders;

import java.util.ArrayList;
import java.util.List;

import books.Book;
import books.BookInfo;
import books.BookInfoHome;

/**
 * BookInfoHome builder.
 */
public class BookInfoHomeBuilder implements IBuilderExampler<BookInfoHome> {

    private BookInfo bookInfo;

    private List<Book> availableCopies;

    private List<Book> borrowedCopies;

    private int timesBorrowed;

    public BookInfoHomeBuilder() {
        this.availableCopies = new ArrayList<Book>();
        this.borrowedCopies = new ArrayList<Book>();
    }

    public BookInfo getBookInfo() {
        return this.bookInfo;
    }

    public void setBookInfo(final BookInfo bookInfo) {
        this.bookInfo = bookInfo;
    }

    public List<Book> getAvailableCopies() {
        return this.availableCopies;
    }

    public void setAvailableCopies(final List<Book> availableCopies) {
        this.availableCopies = availableCopies;
    }

    public List<Book> getBorrowedCopies() {
        return this.borrowedCopies;
    }

    public void setBorrowedCopies(final List<Book> borrowedCopies) {
        this.borrowedCopies = borrowedCopies;
    }

    public void setTimesBorrowed(final int timesBorrowed) {
        this.timesBorrowed = timesBorrowed;
    }

    public int getTimesBorrowed() {
        return this.timesBorrowed;
    }

    @Override
    public BookInfoHome build() {
        return new BookInfoHome(this);
    }

    public BookInfoHomeBuilder withBookInfo(final BookInfo aBookInfo) {
        this.bookInfo = aBookInfo;
        return this;
    }

    public BookInfoHomeBuilder withBorrwedTimes(final int times) {
        this.timesBorrowed = times;
        return this;
    }

    public BookInfoHomeBuilder andAvailableCopy(final Book copy) {
        this.availableCopies.add(copy);
        return this;
    }

    public BookInfoHomeBuilder withAvailableCopy(final Book copy) {
        this.availableCopies.add(copy);
        return this;
    }

    public BookInfoHomeBuilder withBorrowedCopy(final Book copy) {
        this.borrowedCopies.add(copy);
        return this;
    }

    public BookInfoHomeBuilder andBorrowedCopy(final Book copy) {
        this.borrowedCopies.add(copy);
        return this;
    }

    @Override
    public BookInfoHome example() {
        return new BookInfoHomeBuilder().withBookInfo(new BookInfoBuilder().example()).withBorrwedTimes(10)
                .withAvailableCopy(new BookBuilder().example()).withBorrowedCopy(new BookBuilder().example()).build();
    }
}
